//	---------------------------------------------------------------------------
//	dark-matter-data
//	Copyright (c) 2014 dark-matter-data committers
//	---------------------------------------------------------------------------
//	This program is free software; you can redistribute it and/or modify it
//	under the terms of the GNU Lesser General Public License as published by the
//	Free Software Foundation; either version 3 of the License, or (at your
//	option) any later version.
//	This program is distributed in the hope that it will be useful, but WITHOUT
//	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
//	more details.
//	You should have received a copy of the GNU Lesser General Public License along
//	with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
//	---------------------------------------------------------------------------
package org.dmd.gpb.tools.protoparsing.generated.dmw;

// Generated from: org.dmd.util.codegen.ImportManager.getFormattedImports(ImportManager.java:82)
// Called from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:442)
import java.util.ArrayList;                                                          // To support getMVCopy() - (BaseDMWGenerator.java:1181)
import org.dmd.dmc.*;                                                                // If any attributes - (BaseDMWGenerator.java:1087)
import org.dmd.dmc.definitions.DmcDefinitionIF;                                      // The object is a domain specific definition - (BaseDMWGenerator.java:411)
import org.dmd.dmc.types.DefinitionName;                                             // Is named by - (BaseDMWGenerator.java:1062)
import org.dmd.dms.ClassDefinition;                                                  // Passing derived class def up the hierarchy - (BaseDMWGenerator.java:1067)
import org.dmd.dms.generated.dmo.MetaDMSAG;                                          // Required for MODREC constructor - (BaseDMWGenerator.java:1072)
import org.dmd.dms.generated.types.DmcTypeModifierMV;                                // Required for MODREC constructor - (BaseDMWGenerator.java:1071)
import org.dmd.gpb.tools.protoparsing.extended.ProtoElement;                         // Is reference type - (BaseDMWGenerator.java:1107)
import org.dmd.gpb.tools.protoparsing.extended.ProtoMainElement;                     // Derived class - (BaseDMWGenerator.java:1248)
import org.dmd.gpb.tools.protoparsing.extended.ProtoMessage;                         // Required for getModificationRecorder() - (BaseDMWGenerator.java:1076)
import org.dmd.gpb.tools.protoparsing.generated.dmo.DmdprotoDMSAG;                   // Attribute elements from the dmdproto schema - (BaseDMWGenerator.java:897)
import org.dmd.gpb.tools.protoparsing.generated.dmo.ProtoElementDMO;                 // For multi-valued adds of ProtoElement - (BaseDMWGenerator.java:1767)
import org.dmd.gpb.tools.protoparsing.generated.dmo.ProtoMessageDMO;                 // Class not auxiliary or abstract - (BaseDMWGenerator.java:1252)
import org.dmd.gpb.tools.protoparsing.generated.dmw.ProtoElementIterableDMW;         // For multi-valued ProtoElement - (BaseDMWGenerator.java:1709)



/**
 * <P>
 * Generated from the dmdproto schema at version unknown
 * <P>
 * This code was auto-generated by the dmggenerator utility and shouldn't be alterred manually!
 * Generated from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:479)
 */
abstract public class ProtoMessageDMW extends ProtoMainElement implements DmcDefinitionIF, DmcNamedObjectIF {

    // Generated from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:558)
    public ProtoMessageDMW() {
        super(new ProtoMessageDMO(), org.dmd.gpb.tools.protoparsing.generated.DmdprotoSchemaAG._ProtoMessage);
    }

    // Generated from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:564)
    public ProtoMessageDMW(DmcTypeModifierMV mods) {
        super(new ProtoMessageDMO(mods), org.dmd.gpb.tools.protoparsing.generated.DmdprotoSchemaAG._ProtoMessage);
    }

    // Generated from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:606)
    public ProtoMessage getModificationRecorder(){
        ProtoMessage rc = new ProtoMessage();
        rc.setName(getName());
        rc.setModifier(new DmcTypeModifierMV(MetaDMSAG.__modify));
        return(rc);
    }

    // Generated from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:627)
    public ProtoMessageDMW(ProtoMessageDMO obj) {
        super(obj, org.dmd.gpb.tools.protoparsing.generated.DmdprotoSchemaAG._ProtoMessage);
    }

    public ProtoMessage cloneIt() {
        ProtoMessage rc = new ProtoMessage();
        rc.setDmcObject(getDMO().cloneIt());
        return(rc);
    }

    public ProtoMessageDMO getDMO() {
        return((ProtoMessageDMO) core);
    }

    // Generated from: org.dmd.dmg.generators.BaseDMWGenerator.dumpWrapper(BaseDMWGenerator.java:642)
    protected ProtoMessageDMW(ProtoMessageDMO obj, ClassDefinition cd) {
        super(obj,cd);
    }

    // org.dmd.dmg.generators.BaseDMWGenerator.getAccessFunctions(BaseDMWGenerator.java:1297)
    public DefinitionName getObjectName(){
        return(((ProtoMessageDMO) core).getName());
    }

    public int hashCode(){
        return(getObjectName().hashCode());
    }

    public DmcAttribute<?> getObjectNameAttribute(){
        return(((ProtoMessageDMO) core).getObjectNameAttribute());
    }

    public boolean equals(Object obj){
        if (obj instanceof ProtoMessageDMW){
            return( getObjectName().equals( ((ProtoMessageDMW) obj).getObjectName()) );
        }
        return(false);
    }

    /**
     * @return The number of ProtoElement items.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1671)
    public int getElementsSize(){
        return(((ProtoMessageDMO) core).getElementsSize());
    }

    /**
     * @return true if there are no ProtoElementDMO items.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1679)
    public boolean getElementsIsEmpty(){
        if (((ProtoMessageDMO) core).getElementsSize() == 0)
            return(true);
        return(false);
    }

    /**
     * @return true if there are any ProtoElementDMO items.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1689)
    public boolean getElementsHasValue(){
        if (((ProtoMessageDMO) core).getElementsSize() == 0)
            return(false);
        return(true);
    }

    /**
     * @return An Iterator of ProtoElementDMO objects.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1716)
    public ProtoElementIterableDMW getElementsIterable(){
        DmcAttribute<?> attr = core.get(DmdprotoDMSAG.__elements);
        if (attr == null)
            return(ProtoElementIterableDMW.emptyList);
        
        return(new ProtoElementIterableDMW(((ProtoMessageDMO) core).getElements()));
    }

    /**
     * Adds another elements value.
     * @param value A value compatible with ProtoElement
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1773)
    public DmcAttribute<?> addElements(ProtoElement value){
        DmcAttribute<?> attr = ((ProtoMessageDMO) core).addElements(((ProtoElementDMO)value.getDmcObject()));
        return(attr);
    }

    /**
     * Deletes a elements value.
     * @param value The ProtoElement to be deleted from set of attribute values.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1823)
    public void delElements(ProtoElement value){
        ((ProtoMessageDMO) core).delElements(value.getDMO());
    }

    /**
     * @return A COPY of the collection of ProtoElement objects.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:1887)
    public ArrayList<ProtoElement> getElementsCopy(){
        DmcAttribute<?> attr = ((ProtoMessageDMO) core).get(DmdprotoDMSAG.__elements);
        if (attr == null)
            return(new ArrayList<ProtoElement>());
        
        ArrayList<ProtoElement> rc = new ArrayList<ProtoElement>(attr.getMVSize());
        
        ProtoElementIterableDMW it = getElementsIterable();
        while(it.hasNext()){
            rc.add(it.next());
        }
        
        return(rc);
    }

    /**
     * Removes the elements attribute value.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatMV(BaseDMWGenerator.java:2292)
    public void remElements(){
        ((ProtoMessageDMO) core).remElements();
    }

    // org.dmd.dmg.generators.BaseDMWGenerator.formatSV(BaseDMWGenerator.java:1474)
    public DefinitionName getName(){
        return(((ProtoMessageDMO) core).getName());
    }

    /**
     * Sets name to the specified value.
     * @param value A value compatible with DmcTypeDefinitionName
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatSV(BaseDMWGenerator.java:1584)
    public void setName(Object value) throws DmcValueException {
        ((ProtoMessageDMO) core).setName(value);
    }

    /**
     * Sets name to the specified value.
     * @param value DefinitionName
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatSV(BaseDMWGenerator.java:1593)
    public void setName(DefinitionName value){
        ((ProtoMessageDMO) core).setName(value);
    }

    /**
     * Removes the name attribute value.
     */
    // org.dmd.dmg.generators.BaseDMWGenerator.formatSV(BaseDMWGenerator.java:1619)
    public void remName(){
        ((ProtoMessageDMO) core).remName();
    }


}
